<?php // logout.php

/*
 * Copyright 2010 by Mihaela Sabin and Rebecca Lee.  This program is part of DV Unit CMS.
 * DV Unit CMS is free software.  It comes with absolutely no warranty.
 * You can redistribute it and/or modify it under the terms of the Creative Commons
 * Attribution 3.0 United States License. as published by the Free Software Foundation
 * (see <http://creativecommons.org/licenses/by/3.0/us/ for more information).
*/

require_once 'header.php';
function destroySession() {
    $_SESSION = array();

    if (session_id() != "" || isset($_COOKIE[session_name()])) {
        setcookie(session_name(), '', time() - 2592000, '/');
    }

    session_destroy();
}
echo "<center><h3>Log out</h3></center>";

if (isset($_SESSION['user'])) {
    destroySession();
    header("location:login1.php");
}
else echo "<center>You are not logged in</center>";

?>